import { defineConfig } from "rollup";
import { readFileSync } from "node:fs";
import typescript from 'rollup-plugin-typescript2';
import { getBabelOutputPlugin } from "@rollup/plugin-babel";
// import buildEndUploadBundle from "./plugins/upload-source.js"
import docGenerate from "./plugins/doc-generate.js"

const packageJson = JSON.parse(
  readFileSync(new URL("./package.json", import.meta.url))
)

export default defineConfig({
  input: "src/index.ts",
  plugins:[
    typescript(),
    docGenerate(),
    // buildEndUploadBundle(),
  ],
  output: [
    {
      name: packageJson.name,
      file: packageJson.main,
      format: "umd",
      exports: "named",
      plugins: [
        getBabelOutputPlugin({
          allowAllFormats: true,
          presets: ["@babel/preset-env"],
          plugins: [["@babel/plugin-transform-runtime", { useESModules: false }]],
        }),
      ],
    },
  ],
});
